package com.zsc.roadsys.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zsc.roadsys.entity.Role;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author haoran
 */

@Mapper
public interface RoleMapper extends BaseMapper<Role> {

    /**
     * 根据用户id查询所有的权限
     * @param id 用户id
     * @return  查找到用户，返回包含用户对象的list，查不到，返回长度为0的list
     */
    @Select("SELECT r.* FROM user_role ur, role r where ur.user_id = #{id}  AND ur.role_id = r.id")
    public List<Role> listRolesByUserId(Long id);
}
